<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="订单号" prop="orderId">
        <el-input v-model="queryParams.orderId" placeholder="请输入订单号" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="sellerStoreAccountLogList" border stripe
              @selection-change="handleSelectionChange">
      <el-table-column label="订单号" align="center" prop="orderId"></el-table-column>
      <el-table-column label="卖家全称" align="center" prop="storeName"></el-table-column>
      <el-table-column label="国家" align="center" prop="country">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.county_code"
                    :value="scope.row.country"></dict-tag>
        </template>
      </el-table-column>
      <el-table-column label="产品主图" align="center" prop="sellerId">
        <template slot-scope="scope">
          <image-preview :src="scope.row.productImg"></image-preview>
        </template>
      </el-table-column>
      <el-table-column label="商品编码" align="center" prop="skuCode"/>
      <el-table-column label="数量" align="center" prop="num"/>
      <el-table-column label="订单创建时间" align="center" prop="gmtCreate"/>
    </el-table>

    <!--    <pagination-->
    <!--      v-show="total>0"-->
    <!--      :total="total"-->
    <!--      :page.sync="queryParams.pageNum"-->
    <!--      :limit.sync="queryParams.pageSize"-->
    <!--      @pagination="getList"-->
    <!--    />-->
  </div>
</template>

<script>

import {isEvaluationOrder} from "@/api/evaluation/evaluation";

export default {
  dicts: ['county_code'],
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 手工账日志记录表格数据
      sellerStoreAccountLogList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderId: undefined,
      },
      // 表单参数
      form: {expenseType: "测评费用",},
      storeList: [],// 卖家列表
      userList: [],// 卖家列表
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询测评订单列表 */
    getList() {
      this.loading = true;
      isEvaluationOrder(this.queryParams).then(res => {
        this.sellerStoreAccountLogList = res
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        flowType: undefined,
        expenseType: "测评费用",
        payType: undefined,
        userId: undefined,
        money: undefined,
        orderNo: undefined,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "新增测评金额";
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.buttonLoading = true;
          this.form.expenseType = 14
          updateEvaluationAmount(this.form).then(response => {
            this.$modal.msgSuccess("新增成功");
            this.open = false;
            this.getList();
          }).finally(() => {
            this.buttonLoading = false;
          });
        }
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('seller/sellerStoreAccountLog/export', {
        ...this.queryParams
      }, `sellerStoreAccountLog_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
